var readline = require('readline-sync')
readline.setDefaultOptions({ prompt: '' })
var readline = readline.prompt
let str = readline()
let left = str.length - 1
let right = str.length - 1
let result = []
while (left >= 0) {
  if (str[left] !== ' ') {
    //找到第一个不是空格的
    right = left // 这个就是右边界
    while (left >= 0 && str[left] !== ' ') {
      // 找到第一个是空格的 
      left--
    }
    result.push(str.slice(left + 1, right + 1))
  }
  left--
}
console.log(result.join(' '))